﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Eflong.Config;
using Eflong.Config.DataFilter;
using Eflong.MonitoringLib.MonitoringUnit;

namespace KWBridge
{
    public partial class DataFilterForm : Form
    {
        public DataFilterForm( )
        {
            InitializeComponent( );
        }

        private LimitSetConfiguration LimitSetConfig
        {
            get { return LimitSetConfigurationManager.Config; }
        }

        private DataFilterConfiguration DataFilterConfig
        {
            get { return DataFilterConfigurationManager.Config; }
        }

        private void LimitForm_Load( object sender , EventArgs e )
        {
            txtDevIDBegin.Text = DataFilterConfig.DevID.Begin;
            txtDevIDEnd.Text = DataFilterConfig.DevID.End;
            txtDevIDContain.Text = DataFilterConfig.DevID.Contain;
            txtDevIDEqual.Text = DataFilterConfig.DevID.Equal;

            txtDevNameBegin.Text = DataFilterConfig.DevName.Begin;
            txtDevNameEnd.Text = DataFilterConfig.DevName.End;
            txtDevNameContain.Text = DataFilterConfig.DevName.Contain;
        }

        private void btnSave_Click( object sender , EventArgs e )
        {
            DataFilterConfig.DevID.Begin = txtDevIDBegin.Text;
            DataFilterConfig.DevID.End = txtDevIDEnd.Text;
            DataFilterConfig.DevID.Contain = txtDevIDContain.Text;
            DataFilterConfig.DevID.Equal = txtDevIDEqual.Text;

            DataFilterConfig.DevName.Begin = txtDevNameBegin.Text;
            DataFilterConfig.DevName.End = txtDevNameEnd.Text;
            DataFilterConfig.DevName.Contain = txtDevNameContain.Text;

            DataFilterConfigurationManager.SubmitChanges( );

            MessageBox.Show( "设置成功，需要重启软件才能生效！" );
        }
    }
}